Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy tenant with Short URL #1804

Merged

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Feb 23, 2024

Description

This PR fixes the bug described in #1769 where copying the short url is not including tenant information as a url param.

Category

Bug fix

Issues Resolved

Testing

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Craig Perkins <[email protected]>
@derek-ho
Copy link
Collaborator

Blocked on: #1783, since github actions were moved out of security repo

@derek-ho
Copy link
Collaborator

derek-ho commented Feb 26, 2024

@cwperks can you run yarn lint:es --fix?

@derek-ho
Copy link
Collaborator

derek-ho commented Feb 26, 2024

Will add this linting as a precommit hook as a part of this issue for the future: #1805

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 67.38%. Comparing base (9516bea) to head (1d84775).

Files Patch % Lines
public/services/shared-link.ts 76.92% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1804      +/-   ##
==========================================
- Coverage   67.41%   67.38%   -0.03%     
==========================================
  Files          94       94              
  Lines        2409     2410       +1     
  Branches      321      320       -1     
==========================================
  Hits         1624     1624              
- Misses        707      708       +1     
  Partials       78       78              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cwperks
Copy link
Member Author

cwperks commented Feb 26, 2024

Opened PR in FTR repo that contains tests for this: opensearch-project/opensearch-dashboards-functional-test#1128

Signed-off-by: Craig Perkins <[email protected]>
@cwperks
Copy link
Member Author

cwperks commented Feb 27, 2024

Install Dashboards with Plugin via Binary is failing with:

 FATAL  Error: Cannot find module './authentication_methods_registry.mock'
Require stack:
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/plugins/data_source/server/auth_registry/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/plugins/data_source/server/plugin.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/plugins/data_source/server/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/plugin.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/discovery/plugins_discovery.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/discovery/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/plugins_service.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/cli/serve/serve.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/cli/cli.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/cli/dist.js

Example run: https://github.com/opensearch-project/security-dashboards-plugin/actions/runs/8058358488/job/22011023503?pr=1804

@derek-ho
Copy link
Collaborator

Install Dashboards with Plugin via Binary is failing with:

 FATAL  Error: Cannot find module './authentication_methods_registry.mock'
Require stack:
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/plugins/data_source/server/auth_registry/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/plugins/data_source/server/plugin.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/plugins/data_source/server/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/plugin.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/discovery/plugins_discovery.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/discovery/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/plugins_service.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/plugins/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/core/server/index.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/cli/serve/serve.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/cli/cli.js
- /home/runner/work/security-dashboards-plugin/security-dashboards-plugin/opensearch-dashboards-3.0.0-linux-x64/src/cli/dist.js

Example run: https://github.com/opensearch-project/security-dashboards-plugin/actions/runs/8058358488/job/22011023503?pr=1804

I was seeing this too across a few repos I added the workflow for. It's coming from core I think. I created an issue: opensearch-project/OpenSearch-Dashboards#5952. This workflow is also a good way to catch issues in core 😉

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. Thank you for fixing this bug @cwperks !

@cwperks cwperks added the backport 2.x backport to 2.x branch label Feb 28, 2024
Copy link
Collaborator

@derek-ho derek-ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, going to check out your branch and verify it works as expected

Copy link
Collaborator

@derek-ho derek-ho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason safari is dropping the tenant from the share button, can you take a look?

Signed-off-by: Craig Perkins <[email protected]>
@cwperks
Copy link
Member Author

cwperks commented Feb 29, 2024

For some reason safari is dropping the tenant from the share button, can you take a look?

@derek-ho Pushed a fix. Safari was having an issue with creating a new range instead of replacing the existing range. I pushed a change to get the range if it exists, modify it and add it back.

peternied
peternied previously approved these changes Mar 1, 2024
DarshitChanpura
DarshitChanpura previously approved these changes Mar 1, 2024
public/services/shared-link.ts Show resolved Hide resolved
@cwperks
Copy link
Member Author

cwperks commented Mar 1, 2024

@derek-ho I pushed one more small change. I noticed after more testing that since fixing the bug on short url, it was finally hitting the block where it would replace the text content and it was not correctly assembling the new url with the protocol and hash as well. The last commit fixes that to assemble the full url and add the security_tenant url param before the hash and after the search params. If no search params exist, the delimiter will be ? since its the first url param. If url params already exist, it will add it on with & as the delimeter.

@cwperks cwperks dismissed stale reviews from DarshitChanpura and peternied via 28198d2 March 1, 2024 15:39
Signed-off-by: Craig Perkins <[email protected]>
peternied
peternied previously approved these changes Mar 1, 2024
@cwperks
Copy link
Member Author

cwperks commented Mar 1, 2024

@peternied Sorry for one more push, but I found a way to really simplify the logic with adding the security_tenant as a url param. Instead of re-assembling the url from its constituent components I instead use the URL class from javascript and directly parse the URL string and append a searchParam if its not already there.

This also adds a test for the iFrame logic because the copy link with an iFrame should return an iFrame with an updated src attribute that includes security_tenant as a url param.

@DarshitChanpura DarshitChanpura merged commit c80b64a into opensearch-project:main Mar 2, 2024
15 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 2, 2024
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit c80b64a)
cwperks added a commit that referenced this pull request Mar 4, 2024
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit c80b64a)

Co-authored-by: Craig Perkins <[email protected]>
@derek-ho derek-ho mentioned this pull request Mar 14, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport to 2.x branch v2.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants